Skip to content

Commit ac4611e

Browse files
authored
standardize topic listing (#6620)
- use `get_hierarchical_topics`
1 parent cd0b679 commit ac4611e

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

kitsune/flagit/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ def get_hierarchical_topics(product, cache_timeout=3600):
157157
return cached_topics
158158

159159
topics = list(
160-
Topic.active.filter(products=product).order_by("title").values("id", "title", "parent_id")
160+
Topic.active.filter(products=product, visible=True)
161+
.order_by("title")
162+
.values("id", "title", "parent_id")
161163
)
162164
topic_dict = {}
163165
for topic in topics:

kitsune/questions/jinja2/questions/question_details.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ <h3 class="sidebar-subheading sidebar-nav--heading-item is-accordion-heading">{{
462462
{% if user and user.has_perm('questions.change_question') %}
463463
<select id="details-topic" name="topic">
464464
{% for t in all_topics %}
465-
<option {% if topic and t.id == topic.id %}selected="selected"{% endif %} value="{{ t.id }}">{{ t.title }}</option>
465+
<option {% if topic and t.id == topic.id %}selected="selected"{% endif %} value="{{ t.id }}">{{ t.title|safe }}</option>
466466
{% endfor %}
467467
</select>
468468
{% endif %}

kitsune/questions/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from kitsune.access.decorators import login_required, permission_required
3838
from kitsune.customercare.forms import ZendeskForm
3939
from kitsune.flagit.models import FlaggedObject
40+
from kitsune.flagit.views import get_hierarchical_topics
4041
from kitsune.products.models import Product, Topic, TopicSlugHistory
4142
from kitsune.questions import config
4243
from kitsune.questions.events import QuestionReplyEvent, QuestionSolvedEvent
@@ -450,7 +451,8 @@ def question_details(
450451
extra_kwargs.update(ans_)
451452

452453
products = Product.active.with_question_forums(request)
453-
topics = topics_for(request.user, product=question.product)
454+
# Use get_hierarchical_topics instead of topics_for to match the moderate view
455+
topics = get_hierarchical_topics(question.product) if question.product else []
454456

455457
related_documents = question.related_documents
456458
related_questions = question.related_questions

0 commit comments

Comments
 (0)